<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="asterisk是一个开源的sip服务器，默认情况，asterisk是从sip.conf来配置peers，如果peers有变更或者数量比较大，就不能采用这种方式，asterisk提供的realtime方式，支持数据库实时保存及读取peers，数据库支持mysql、sqlite、postgres等，本文将指导如何进行mysql配置. 步骤1 - 安装并配置mysql可以参考其他文档安装mysql，并">
<meta property="og:type" content="article">
<meta property="og:title" content="asterisk配置mysql来保存peers">
<meta property="og:url" content="http://smallmuou.gitee.io/blog/2017/09/07/2017-09-07-asterisk配置mysql来保存peers/index.html">
<meta property="og:site_name" content="smallmuou&#39;s blog">
<meta property="og:description" content="asterisk是一个开源的sip服务器，默认情况，asterisk是从sip.conf来配置peers，如果peers有变更或者数量比较大，就不能采用这种方式，asterisk提供的realtime方式，支持数据库实时保存及读取peers，数据库支持mysql、sqlite、postgres等，本文将指导如何进行mysql配置. 步骤1 - 安装并配置mysql可以参考其他文档安装mysql，并">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-04-16T01:15:21.903Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="asterisk配置mysql来保存peers">
<meta name="twitter:description" content="asterisk是一个开源的sip服务器，默认情况，asterisk是从sip.conf来配置peers，如果peers有变更或者数量比较大，就不能采用这种方式，asterisk提供的realtime方式，支持数据库实时保存及读取peers，数据库支持mysql、sqlite、postgres等，本文将指导如何进行mysql配置. 步骤1 - 安装并配置mysql可以参考其他文档安装mysql，并">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://smallmuou.gitee.io/blog/2017/09/07/2017-09-07-asterisk配置mysql来保存peers/"/>





  <title>asterisk配置mysql来保存peers | smallmuou's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">smallmuou's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"><a href="https://github.com/smallmuou">https://github.com/smallmuou</a></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2017/09/07/2017-09-07-asterisk配置mysql来保存peers/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">asterisk配置mysql来保存peers</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-07T00:00:00+08:00">
                2017-09-07
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>asterisk是一个开源的sip服务器，默认情况，asterisk是从sip.conf来配置peers，如果peers有变更或者数量比较大，就不能采用这种方式，asterisk提供的realtime方式，支持数据库实时保存及读取peers，数据库支持mysql、sqlite、postgres等，本文将指导如何进行mysql配置.</p>
<h4 id="步骤1-安装并配置mysql"><a href="#步骤1-安装并配置mysql" class="headerlink" title="步骤1 - 安装并配置mysql"></a>步骤1 - 安装并配置mysql</h4><p>可以参考其他文档安装mysql，并配置用户密码</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysqladmin -uroot password <span class="string">'new password'</span></span><br></pre></td></tr></table></figure>
<h4 id="步骤2-创建数据库及表"><a href="#步骤2-创建数据库及表" class="headerlink" title="步骤2 - 创建数据库及表"></a>步骤2 - 创建数据库及表</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">DATABASE</span> asterisk;</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> <span class="keyword">IF</span> <span class="keyword">NOT</span> <span class="keyword">EXISTS</span> <span class="string">`sippeers`</span> (</span><br><span class="line">      <span class="string">`id`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span> AUTO_INCREMENT,</span><br><span class="line">      <span class="string">`name`</span> <span class="built_in">varchar</span>(<span class="number">10</span>) <span class="keyword">NOT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`ipaddr`</span> <span class="built_in">varchar</span>(<span class="number">15</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`port`</span> <span class="built_in">int</span>(<span class="number">5</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`regseconds`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`defaultuser`</span> <span class="built_in">varchar</span>(<span class="number">10</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`fullcontact`</span> <span class="built_in">varchar</span>(<span class="number">64</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`regserver`</span> <span class="built_in">varchar</span>(<span class="number">20</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`useragent`</span> <span class="built_in">varchar</span>(<span class="number">64</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`lastms`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`host`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`type`</span> enum(<span class="string">'friend'</span>,<span class="string">'user'</span>,<span class="string">'peer'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`context`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`permit`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`deny`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`secret`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`md5secret`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`remotesecret`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`transport`</span> enum(<span class="string">'udp'</span>,<span class="string">'tcp'</span>,<span class="string">'udp,tcp'</span>,<span class="string">'tcp,udp'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`dtmfmode`</span> enum(<span class="string">'rfc2833'</span>,<span class="string">'info'</span>,<span class="string">'shortinfo'</span>,<span class="string">'inband'</span>,<span class="string">'auto'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`directmedia`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>,<span class="string">'nonat'</span>,<span class="string">'update'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`nat`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>,<span class="string">'never'</span>,<span class="string">'route'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`callgroup`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`pickupgroup`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`language`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`allow`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`disallow`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`insecure`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`trustrpid`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`progressinband`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>,<span class="string">'never'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`promiscredir`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`useclientcode`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`accountcode`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`setvar`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`callerid`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`amaflags`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`callcounter`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`busylevel`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`allowoverlap`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`allowsubscribe`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`videosupport`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`maxcallbitrate`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`rfc2833compensate`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`mailbox`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`session-timers`</span> enum(<span class="string">'accept'</span>,<span class="string">'refuse'</span>,<span class="string">'originate'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`session-expires`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`session-minse`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`session-refresher`</span> enum(<span class="string">'uac'</span>,<span class="string">'uas'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`t38pt_usertpsource`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`regexten`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`fromdomain`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`fromuser`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`qualify`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`defaultip`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`rtptimeout`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`rtpholdtimeout`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`sendrpid`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`outboundproxy`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`callbackextension`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`registertrying`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`timert1`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`timerb`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`qualifyfreq`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`constantssrc`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`contactpermit`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`contactdeny`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`usereqphone`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`textsupport`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`faxdetect`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`buggymwi`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`auth`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`fullname`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`trunkname`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`cid_number`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`callingpres`</span> enum(<span class="string">'allowed_not_screened'</span>,<span class="string">'allowed_passed_screen'</span>,<span class="string">'allowed_failed_screen'</span>,<span class="string">'allowed'</span>,<span class="string">'prohib_not_screened'</span>,<span class="string">'prohib_passed_screen'</span>,<span class="string">'prohib_failed_screen'</span>,<span class="string">'prohib'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`mohinterpret`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`mohsuggest`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`parkinglot`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`hasvoicemail`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`subscribemwi`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`vmexten`</span> <span class="built_in">varchar</span>(<span class="number">40</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`autoframing`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`rtpkeepalive`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`call-limit`</span> <span class="built_in">int</span>(<span class="number">11</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`g726nonstandard`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`ignoresdpversion`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`allowtransfer`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      <span class="string">`dynamic`</span> enum(<span class="string">'yes'</span>,<span class="string">'no'</span>) <span class="keyword">DEFAULT</span> <span class="literal">NULL</span>,</span><br><span class="line">      PRIMARY <span class="keyword">KEY</span> (<span class="string">`id`</span>),</span><br><span class="line">      <span class="keyword">UNIQUE</span> <span class="keyword">KEY</span> <span class="string">`name`</span> (<span class="string">`name`</span>),</span><br><span class="line">      <span class="keyword">KEY</span> <span class="string">`ipaddr`</span> (<span class="string">`ipaddr`</span>,<span class="string">`port`</span>),</span><br><span class="line">      <span class="keyword">KEY</span> <span class="string">`host`</span> (<span class="string">`host`</span>,<span class="string">`port`</span>)</span><br><span class="line">) <span class="keyword">ENGINE</span>=MyISAM;</span><br></pre></td></tr></table></figure>
<h4 id="步骤3-编译asterisk的mysql模块"><a href="#步骤3-编译asterisk的mysql模块" class="headerlink" title="步骤3 - 编译asterisk的mysql模块"></a>步骤3 - 编译asterisk的mysql模块</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make menuconfig</span><br></pre></td></tr></table></figure>
<p>勾选 addons-&gt;res_config_mysql，并重新make &amp;&amp; make install</p>
<h4 id="步骤4-配置res-config-mysql-conf"><a href="#步骤4-配置res-config-mysql-conf" class="headerlink" title="步骤4 - 配置res_config_mysql.conf"></a>步骤4 - 配置res_config_mysql.conf</h4><p>vim /etc/asterisk/res_config_mysql.conf<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[general]</span><br><span class="line">dbhost = 127.0.0.1</span><br><span class="line">dbname = asterisk</span><br><span class="line">dbuser = root</span><br><span class="line">dbpass = 123456</span><br><span class="line">dbport = 3306</span><br><span class="line">dbsock = /var/lib/mysql/mysql.sock</span><br><span class="line">dbcharset = utf8</span><br></pre></td></tr></table></figure></p>
<p>ps: dbname数据库名字， dbsock为mysql的本地sock文件，需要根据自己环境变更</p>
<h4 id="步骤5-配置extconfig-conf"><a href="#步骤5-配置extconfig-conf" class="headerlink" title="步骤5 - 配置extconfig.conf"></a>步骤5 - 配置extconfig.conf</h4><p>vim /etc/asterisk/extconfig.conf<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sippeers =&gt; mysql,general,sippeers</span><br></pre></td></tr></table></figure></p>
<p>ps: general是对应res_config_mysql.conf的段名（中括号部分）， sippeers为数据库表名</p>
<h4 id="步骤6-插入用户信息"><a href="#步骤6-插入用户信息" class="headerlink" title="步骤6 - 插入用户信息"></a>步骤6 - 插入用户信息</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> sippeers (<span class="keyword">name</span>, host, secret) <span class="keyword">values</span> (<span class="string">'111'</span>, <span class="string">'dynamic'</span>, <span class="string">'111'</span>);</span><br></pre></td></tr></table></figure>
<p>ps: name用户名，secret密码，host必须指定为dynamic，否则注册不了</p>
<h4 id="步骤7-启动asterisk"><a href="#步骤7-启动asterisk" class="headerlink" title="步骤7 - 启动asterisk"></a>步骤7 - 启动asterisk</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">asterisk</span><br></pre></td></tr></table></figure>
<p>此时就可以正常注册了，客户端的一些信息就会更新到mysql，如果发现未更新，说明可能更新失败，请查看asterisk控制台的报错信息，一般是某些字段长度超出了mysql表定义的长度。</p>
<p>以上是我配置的整个过程，当然中间踩了很多坑，不过都可以通过asterisk控制台找出具体原因.s</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2017/09/05/2017-09-05-快速展现和保存16进制/" rel="next" title="快速展现和保存16进制">
                <i class="fa fa-chevron-left"></i> 快速展现和保存16进制
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2017/09/11/2017-09-11-如何解决域名访问腾讯云-该网站暂时无法访问-问题/" rel="prev" title="如何解决域名访问腾讯云-该网站暂时无法访问-问题">
                如何解决域名访问腾讯云-该网站暂时无法访问-问题 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">smallmuou</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">197</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/smallmuou" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-globe"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#步骤1-安装并配置mysql"><span class="nav-number">1.</span> <span class="nav-text">步骤1 - 安装并配置mysql</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#步骤2-创建数据库及表"><span class="nav-number">2.</span> <span class="nav-text">步骤2 - 创建数据库及表</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#步骤3-编译asterisk的mysql模块"><span class="nav-number">3.</span> <span class="nav-text">步骤3 - 编译asterisk的mysql模块</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#步骤4-配置res-config-mysql-conf"><span class="nav-number">4.</span> <span class="nav-text">步骤4 - 配置res_config_mysql.conf</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#步骤5-配置extconfig-conf"><span class="nav-number">5.</span> <span class="nav-text">步骤5 - 配置extconfig.conf</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#步骤6-插入用户信息"><span class="nav-number">6.</span> <span class="nav-text">步骤6 - 插入用户信息</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#步骤7-启动asterisk"><span class="nav-number">7.</span> <span class="nav-text">步骤7 - 启动asterisk</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">smallmuou</span>

  
</div>

    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    <span id="busuanzi_container_site_pv">总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
